const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    price:'',
    totalprice:'',
    restaurantId:'',
    types:'',
    list: {
    },
    urls:'',
    billId:'',
    total:'',//总价
    table:'',//桌子
    people:'',//人数
    order:'',
addressid:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let price=options.price
    let totalprice = options.totalprice
    let total = options.totalprice
    let billId = options.billId
    let restaurantId = options.restaurantId
    let order=options.order
    let types=options.types
    console.log(types)
    this.setData({
      price: price,
      totalprice: totalprice,
      restaurantId: restaurantId,
      billId:billId,
      order:order,
      types:types,
      total: total
    })
    this.userDefulAddress(billId, types)
    this.shop_card(billId)
  },
  //获取餐桌
  userDefulAddress(billId, types){
    var userId = app.globalDataO.openid.objectSid
    app.post(app.url.userDefulAddress, { wechatId: userId, bill_id: billId, type:types}).then(res=>{
      var table = res.data.desk
      this.setData({
        people:res.data.people,
        table: res.data.desk
      })
    })
  },
  //查看购物车
  shop_card(billId) {
    var that = this
    app.post(app.url.billLine, {
      billId: billId
    }).then(res => {
      console.log(res.data)
      if (res.data.billLine == "" || res.data.billLine == null) {
        return false;
        wx.showToast({
          title: '出错啦',
        })
      } else {
        that.setData({
          list:res.data,
          urls:res.data.urls
        })
      }

    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },
  clickSendData(){
  console.log()
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})